﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PC.PickleJar.Attributes
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
	public class ItemTimestampAttribute : Attribute
	{
		public ItemTimestampAttribute(String universalSortableDateTime)
		{
			DateTime value;
			if (!DateTime.TryParse(universalSortableDateTime, out value) ||
				universalSortableDateTime.Trim() != value.ToUniversalTime().ToString("u"))
			{
				throw new FormatException("Time must be in Universable Sortable DateTime Pattern (format string \"u\").");
			}

			this.Timestamp = value;
		}

		public DateTime Timestamp
		{
			get;
			private set;
		}
	}
}
